<template>
  <div>
    <ol class="tabs">
      <li v-for="item in dataSource" :key="item.value"
          :class="{[classPrefix+'-item']:classPrefix,selected:value===item.value}"
          @click="selected(item.value)">{{ item.text }}
      </li>
    </ol>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
import {Component, Prop} from 'vue-property-decorator';

@Component
export default class Types extends Vue {
  @Prop({required: true, type: Array}) dataSource!: DataSourceItem[];
  @Prop(String) readonly value!: string;
  @Prop(String) classPrefix?: string;

  selected(value: string) {
    this.$emit('update:value', value);
  }
}
</script>

<style lang="scss" scoped>
.tabs {
  background-color: #c4c4c4;
  display: flex;
  font-size: 24px;

  > li {
    height: 64px;
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    position: relative;

    &.selected::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 4px;
      background-color: #333;
    }
  }
}
</style>
